import { defineStore } from "pinia";
import { createApp } from "vue";
import Sign from "@/components/Sign.vue";

const appStore = defineStore("appStore", {
  state: (): AppState => ({
    showSign: false,
  }),
  actions: {
    openSign() {
      this.showSign = true;
      const mask = document.createElement("div");
      mask.id = "sign-mask";
      document.body.appendChild(mask);
      createApp(Sign).mount("#sign-mask");
    },

    closeSign() {
      this.showSign = false;
      const mask = document.getElementById("sign-mask");
      if (mask) {
        mask.remove();
        document.body.removeChild(mask);
      }
    },
  },
});

export default appStore;
